package com.gpt.article.service.impl.taskHandle.testTask;


/**
 * @auther 言行
 */
public class SellTicket {
    Runnable runnable = new Runnable() {

        int ticket = 1;//100张票
        public void run() {
            while (true) {
                if (ticket < 218101) {
                    //卖出一张票并且打印
                    System.out.println(Thread.currentThread().getName() + "__" + ticket++);
                }else{
                    System.out.println("结束...");
                    try {
                        Thread.sleep(5555555);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    };

    public static void main(String[] args) {
        new SellTicket().runspider();
    }
    public  void runspider() {
        Thread thread1 = new Thread(runnable);
        Thread thread2 = new Thread(runnable);
        Thread thread3 = new Thread(runnable);

        thread1.start();
        thread2.start();
        thread3.start();
    }
}